//
//  RepairDetailView.m
//  智慧小区
//
//  Created by lab603 on 15/6/30.
//  Copyright (c) 2015年 Dreamsoul. All rights reserved.
//

#import "RepairDetailView.h"
#import "PPPicturesView.h"
#import "Repair.h"
#import "PPPicture.h"
#import "VoiceDefineBtn.h"
#define padding 10
#define pictureWH 40
#define processViewW (ScreenWidth- 30*2 -pictureWH*3 - padding*4)*0.5
@interface RepairDetailView()
//进度图
@property (nonatomic,weak) UIImageView *processView;

//提交图
@property (nonatomic,weak) UIImageView *commitImage;
//提交
@property (nonatomic,weak) UILabel *commitLabel;
//处理中图
@property (nonatomic,weak) UIImageView *dealImage;
//处理
@property (nonatomic,weak) UILabel *dealLabel;
//完成图
@property (nonatomic,weak) UIImageView *completeView;
//完成
@property (nonatomic,weak) UILabel *completeLabel;
//进度条1
@property (nonatomic,weak) UIImageView *processImageOne;
//进度条2
@property (nonatomic,weak) UIImageView *processImageTwo;

//细节图
@property (nonatomic,weak) UIImageView *detailView;
//详情Icon
@property (nonatomic,weak) UIImageView *detailIcon;
//详情Label
@property (nonatomic,weak) UILabel *detailLabel;
//分割线
@property (nonatomic,weak) UIImageView *detailSeparator;
//业主姓名
@property (nonatomic,weak) UILabel *nameLabel;
//业主手机
@property (nonatomic,weak) UILabel *phoneLabel;
//报修时间
@property (nonatomic,weak) UILabel *timeLabel;
//报修类型
@property (nonatomic,weak) UILabel *repairTypeLabel;
//报修详情
@property (nonatomic,weak) UILabel *repairDetailLabel;
//语音信息
@property (nonatomic,weak) UILabel *voiceLabel;
//语音按钮
@property (nonatomic,weak) VoiceDefineBtn *voiceBtn;
//图片描述
@property (nonatomic,weak) UILabel *pictureLabel;
//存放图片的View
@property (nonatomic,weak) PPPicturesView *picturesView;

//维修信息
@property (nonatomic,weak) UIImageView *repairView;
//维修Icon
@property (nonatomic,weak) UIImageView *repairIcon;
//维修Label
@property (nonatomic,weak) UILabel *repairLabel;
//分割线
@property (nonatomic,weak) UIImageView *repairSeparator;
//维修人员
@property (nonatomic,weak) UILabel *repairName;
//联系电话
@property (nonatomic,weak) UILabel *repairPhone;
//处理时间
@property (nonatomic,weak) UILabel *dealTime;
//完成时间
@property (nonatomic,weak) UILabel *completeTime;

//评价按钮
@property (nonatomic,weak) UIButton *evaluateBtn;
@end
@implementation RepairDetailView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //添加细节图
        UIImageView *processView = [[UIImageView alloc] init];
        processView.backgroundColor = [UIColor whiteColor];
        [self addSubview:processView];
        _processView = processView;
        //提交图
        UIImageView *commitImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"action_edit"] highlightedImage:[UIImage imageNamed:@"action_edit_selected"]];
        [self.processView addSubview:commitImage];
        _commitImage = commitImage;
        //提交
        UILabel *commitLabel = [[UILabel alloc] init];
        commitLabel.font = [UIFont systemFontOfSize:13.0];
        commitLabel.textColor = IWColor(240, 64, 15);
        commitLabel.backgroundColor = [UIColor clearColor];
        [self.processView addSubview:commitLabel];
        _commitLabel = commitLabel;
        //处理中图
        UIImageView *dealImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_tab_search_normal"] highlightedImage:[UIImage imageNamed:@"icon_tab_search_checked"]];
        [self.processView addSubview:dealImage];
        _dealImage =dealImage;
        //处理
        UILabel *dealLabel = [[UILabel alloc] init];
        dealLabel.font = [UIFont systemFontOfSize:13.0];
        dealLabel.textColor = App_Separator_Color;
        dealLabel.backgroundColor = [UIColor clearColor];
        [self.processView addSubview:dealLabel];
        _dealLabel = dealLabel;
        //完成图
        UIImageView *completeImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_tab_arts_normal"] highlightedImage:[UIImage imageNamed:@"icon_tab_arts_checked"]];
        [self.processView addSubview:completeImage];
        _completeView =completeImage;
        //完成
        UILabel *completeLabel = [[UILabel alloc] init];
        completeLabel.font = [UIFont systemFontOfSize:13.0];
        completeLabel.textColor = App_Separator_Color;
        completeLabel.backgroundColor = [UIColor clearColor];
        [self.processView addSubview:completeLabel];
        _completeLabel = completeLabel;
        //进度条one
        UIImageView *processOne = [[UIImageView alloc] init];
        processOne.backgroundColor = App_Separator_Color;
        [self.processView addSubview:processOne];
        _processImageOne = processOne;
        //进度条two
        UIImageView *processTwo = [[UIImageView alloc] init];
        processTwo.backgroundColor = App_Separator_Color;
        [self.processView addSubview:processTwo];
        _processImageTwo = processTwo;
        
        //细节图
        UIImageView *detailView = [[UIImageView alloc] init];
        detailView.backgroundColor = [UIColor whiteColor];
        detailView.userInteractionEnabled = YES;
        [self addSubview:detailView];
        _detailView =detailView;
        //详情的Icon
        UIImageView *detailIcon = [[UIImageView alloc] init];
        detailIcon.image = [UIImage imageNamed:@"gallery_page_shop_copy"];
        [self.detailView addSubview:detailIcon];
        _detailIcon =detailIcon;
        //详情Label
        UILabel *detailLabel = [[UILabel alloc] init];
        detailLabel.font = [UIFont systemFontOfSize:15.0];
        detailLabel.textColor = [UIColor blackColor];
        detailLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:detailLabel];
        _detailLabel = detailLabel;
        //分割线
        UIImageView *detailSeparator = [[UIImageView alloc] init];
        detailSeparator.backgroundColor = App_Separator_Color;
        [self.detailView addSubview:detailSeparator];
        _detailSeparator = detailSeparator;
        //业主姓名
        UILabel *nameLabel = [[UILabel alloc] init];
        nameLabel.font = [UIFont systemFontOfSize:14.0];
        nameLabel.textColor = [UIColor blackColor];
        nameLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:nameLabel];
        _nameLabel = nameLabel;
        //手机号码
        UILabel *phoneLabel = [[UILabel alloc] init];
        phoneLabel.font = [UIFont systemFontOfSize:14.0];
        phoneLabel.textColor = [UIColor blackColor];
        phoneLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:phoneLabel];
        _phoneLabel = phoneLabel;
        //报修时间
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.font = [UIFont systemFontOfSize:14.0];
        timeLabel.textColor = [UIColor blackColor];
        timeLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:timeLabel];
        _timeLabel = timeLabel;
        //报修类型
        UILabel *repairTypeLabel = [[UILabel alloc] init];
        repairTypeLabel.font = [UIFont systemFontOfSize:14.0];
        repairTypeLabel.textColor = [UIColor blackColor];
        repairTypeLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:repairTypeLabel];
        _repairTypeLabel = repairTypeLabel;
        //报修详情
        UILabel *repairDetailLabel = [[UILabel alloc] init];
        repairDetailLabel.font = [UIFont systemFontOfSize:14.0];
        repairDetailLabel.textColor = [UIColor blackColor];
        repairDetailLabel.backgroundColor = [UIColor clearColor];
        repairDetailLabel.numberOfLines = 0;
        [self.detailView addSubview:repairDetailLabel];
        _repairDetailLabel = repairDetailLabel;
        //语音
        UILabel *voiceLabel = [[UILabel alloc] init];
        voiceLabel.font = [UIFont systemFontOfSize:14.0];
        voiceLabel.textColor = [UIColor blackColor];
        voiceLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:voiceLabel];
        _voiceLabel = voiceLabel;
        //语音按钮
        VoiceDefineBtn *voiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [voiceBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        voiceBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [voiceBtn setTitle:@"语音播放" forState:UIControlStateNormal];
        voiceBtn.backgroundColor = APP_THEME_COLOR;
        [voiceBtn addTarget:self action:@selector(voiceBtnTapped) forControlEvents:UIControlEventTouchUpInside];
        voiceBtn.layer.cornerRadius = CORNER_RADIUS_5;
        voiceBtn.clipsToBounds = YES;
        [self.detailView addSubview: voiceBtn];
        self.voiceBtn = voiceBtn;
        
        //图片描述
        UILabel *pictureLabel = [[UILabel alloc] init];
        pictureLabel.font = [UIFont systemFontOfSize:14.0];
        pictureLabel.textColor = [UIColor blackColor];
        pictureLabel.backgroundColor = [UIColor clearColor];
        [self.detailView addSubview:pictureLabel];
        _pictureLabel = pictureLabel;
        //存放图片的View
        PPPicturesView *picturesView = [[PPPicturesView alloc] init];
        [self.detailView addSubview:picturesView];
        _picturesView = picturesView;
        
        //维修信息背景
        UIImageView *repairView = [[UIImageView alloc] init];
        repairView.backgroundColor = [UIColor whiteColor];
        [self addSubview:repairView];
        _repairView = repairView;
        //维修的icon
        UIImageView *repairIcon = [[UIImageView alloc] init];
        repairIcon.image = [UIImage imageNamed:@"gallery_page_shop_copy"];
        [self.repairView addSubview:repairIcon];
        _repairIcon =repairIcon;
        //详情Label
        UILabel *repairLabel = [[UILabel alloc] init];
        repairLabel.font = [UIFont systemFontOfSize:15.0];
        repairLabel.textColor = [UIColor blackColor];
        repairLabel.backgroundColor = [UIColor clearColor];
        [self.repairView addSubview:repairLabel];
        _repairLabel = repairLabel;
        //分割线
        UIImageView *repairSeparator = [[UIImageView alloc] init];
        repairSeparator.backgroundColor = App_Separator_Color;
        [self.repairView addSubview:repairSeparator];
        _repairSeparator = repairSeparator;
        //维修师傅
        UILabel *repairName = [[UILabel alloc] init];
        repairName.font = [UIFont systemFontOfSize:14.0];
        repairName.textColor = [UIColor blackColor];
        repairName.backgroundColor = [UIColor clearColor];
        [self.repairView addSubview:repairName];
        _repairName = repairName;
        //联系电话
        UILabel *repairPhone = [[UILabel alloc] init];
        repairPhone.font = [UIFont systemFontOfSize:14.0];
        repairPhone.textColor = [UIColor blackColor];
        repairPhone.backgroundColor = [UIColor clearColor];
        [self.repairView addSubview:repairPhone];
        _repairPhone = repairPhone;
        //处理时间
        UILabel *dealTime = [[UILabel alloc] init];
        dealTime.font = [UIFont systemFontOfSize:14.0];
        dealTime.textColor = [UIColor blackColor];
        dealTime.backgroundColor = [UIColor clearColor];
        [self.repairView addSubview:dealTime];
        _dealTime = dealTime;
        //完成时间
        UILabel *completeTime = [[UILabel alloc] init];
        completeTime.font = [UIFont systemFontOfSize:14.0];
        completeTime.textColor = [UIColor blackColor];
        completeTime.backgroundColor = [UIColor clearColor];
        [self.repairView addSubview:completeTime];
        _completeTime = completeTime;
        
        //评价按钮
        UIButton *evaluateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [evaluateBtn setTitleColor:APP_THEME_COLOR forState:UIControlStateNormal];
        [evaluateBtn setTitle:@"评价" forState:UIControlStateNormal];
        evaluateBtn.backgroundColor = [UIColor whiteColor];
        evaluateBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [evaluateBtn addTarget:self action:@selector(evaluate) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview: evaluateBtn];
        self.evaluateBtn = evaluateBtn;
    }
    return self;
}
- (void)setRepair:(Repair *)repair{
    _repair = repair;
    //设置Frame
    //进度图
    CGFloat processX = 0;
    CGFloat processY = padding;
    CGFloat processW = ScreenWidth;
    //根据子控件来计算
    CGFloat processH = 0;
    
    //提交图
    CGFloat commitX = padding*3;
    CGFloat commitY = padding;
    CGFloat commitW = pictureWH;
    CGFloat commitH = pictureWH;
    self.commitImage.frame = CGRectMake(commitX, commitY, commitW, commitH);
    
    //提交
    NSString *commitString = @"已提交";
    CGSize commitLabelSize = [commitString sizeWithFont:[UIFont systemFontOfSize:13.0]];
    self.commitLabel.bounds = (CGRect){{0,0},commitLabelSize};
    CGFloat commitCenterX = CGRectGetMaxX(self.commitImage.frame)-0.5*commitW;
    CGFloat commitCenterY = CGRectGetMaxY(self.commitImage.frame)+ 0.5*commitLabelSize.width;
    CGPoint commitCenter = CGPointMake(commitCenterX, commitCenterY);
    self.commitLabel.center = commitCenter;
    
    //进度条one
    CGFloat processOneX = CGRectGetMaxX(self.commitImage.frame)+padding;
    CGFloat processOneY = commitY+pictureWH*0.5;
    CGFloat processOneW = processViewW;
    CGFloat processOneH = 1;
    self.processImageOne.frame = CGRectMake(processOneX, processOneY, processOneW, processOneH);
    
    //处理图
    CGFloat dealX = CGRectGetMaxX(self.processImageOne.frame) +padding;
    CGFloat dealY = commitY;
    CGFloat dealW = commitW;
    CGFloat dealH = commitH;
    self.dealImage.frame = CGRectMake(dealX, dealY, dealW, dealH);
    
    //进度条two
    CGFloat processTwoX = CGRectGetMaxX(self.dealImage.frame)+padding;
    CGFloat processTwoY = commitY+pictureWH*0.5;
    CGFloat processTwoW = processViewW;
    CGFloat processTwoH = 1;
    self.processImageTwo.frame = CGRectMake(processTwoX, processTwoY, processTwoW, processTwoH);
    
    //处理
    NSString *dealString = @"处理中";
    CGSize dealLabelSize = [dealString sizeWithFont:[UIFont systemFontOfSize:13.0]];
    self.dealLabel.bounds = (CGRect){{0,0},dealLabelSize};
    CGFloat dealCenterX = CGRectGetMaxX(self.dealImage.frame)-0.5*dealW;
    //CGFloat dealCenterY = CGRectGetMaxY(self.dealImage.frame)+ 0.5*dealLabelSize.width;
    CGFloat dealCenterY = commitCenterY;
    CGPoint dealCenter = CGPointMake(dealCenterX, dealCenterY);
    self.dealLabel.center = dealCenter;
    
    //完成图
    CGFloat completeX = CGRectGetMaxX(self.processImageTwo.frame) +padding;
    CGFloat completeY = commitY;
    CGFloat completeW = commitW;
    CGFloat completeH = commitH;
    self.completeView.frame = CGRectMake(completeX, completeY, completeW, completeH);
    
    //完成
    NSString *completeString = @"已完成";
    CGSize completeLabelSize = [completeString sizeWithFont:[UIFont systemFontOfSize:13.0]];
    self.completeLabel.bounds = (CGRect){{0,0},completeLabelSize};
    CGFloat completeCenterX = CGRectGetMaxX(self.completeView.frame)-0.5*completeW;
    CGFloat completeCenterY = dealCenterY;
    CGPoint completeCenter = CGPointMake(completeCenterX, completeCenterY);
    self.completeLabel.center = completeCenter;
    
    //算出进度图的frame
    processH = CGRectGetMaxY(self.commitLabel.frame)+padding;
    self.processView.frame = CGRectMake(processX, processY, processW, processH);
    
    //细节图
    CGFloat detailViewX = 0;
    CGFloat detailViewY = CGRectGetMaxY(self.processView.frame)+padding;
    CGFloat detailViewW = ScreenWidth;
    //细节图的高度待定
    CGFloat detailViewH = 0;
    
    //细节Icon
    CGFloat detailIconX = padding*2;
    CGFloat detailIconY = padding *0.5;
    CGSize  detailIconSize = (CGSize){20,20};
    _detailIcon.frame = (CGRect){{detailIconX,detailIconY},detailIconSize};
    
    //报修详情Label
    CGFloat detailLabelX = CGRectGetMaxX(_detailIcon.frame)+padding*0.5;
    CGFloat detailLabelY = detailIconY;
    CGSize detailLabelSize = [@"报修详情" sizeWithFont:[UIFont systemFontOfSize:15.0]];
    _detailLabel.frame = (CGRect){{detailLabelX,detailLabelY},detailLabelSize};
    
    //分割线
    CGFloat detailSeparatorX = detailIconX;
    CGFloat detailSeparatorY = CGRectGetMaxY(_detailIcon.frame)+padding*0.5;
    CGSize detailSeparatorSize = (CGSize){ScreenWidth-detailIconX,1};
    _detailSeparator.frame = (CGRect){{detailSeparatorX,detailSeparatorY},detailSeparatorSize};
    
    //业主
    CGFloat nameLabelX = padding*2;
    CGFloat nameLabelY = CGRectGetMaxY(_detailSeparator.frame)+padding;
    NSString *nameString = [NSString stringWithFormat:@"业主姓名 : %@",self.repair.contact];
    CGSize nameLabelSize = [nameString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.nameLabel.frame = (CGRect){{nameLabelX,nameLabelY},nameLabelSize};
    
    //电话
    CGFloat phoneLabelX = nameLabelX;
    CGFloat phoneLabelY = CGRectGetMaxY(self.nameLabel.frame)+padding;
    NSString *phoneString = [NSString stringWithFormat:@"手机号码 : %@",self.repair.phone];
    CGSize phoneLabelSize = [phoneString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.phoneLabel.frame = (CGRect){{phoneLabelX,phoneLabelY},phoneLabelSize};
    
    //报修时间
    CGFloat timeLabelX = phoneLabelX;
    CGFloat timeLabelY = CGRectGetMaxY(self.phoneLabel.frame)+padding;
    NSString *timeLabelString = [NSString stringWithFormat:@"报修时间 : %@",self.repair.timeOne];
    CGSize timeLabelSize = [timeLabelString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.timeLabel.frame = (CGRect){{timeLabelX,timeLabelY},timeLabelSize};
    
    //报修类型
    NSString *typeString = @"";
    switch (repair.type) {
        case 1:
            typeString = @"给排水维修";
            break;
        case 2:
            typeString = @"室内电气维修";
            break;
        case 3:
            typeString = @"门窗维修";
            break;
        case 4:
            typeString = @"保洁服务";
            break;
        case 5:
            typeString = @"其他";
            break;
    }
    CGFloat repairTypeLabelX = phoneLabelX;
    CGFloat repairTypeLabelY = CGRectGetMaxY(self.timeLabel.frame)+padding;
    NSString *repairTypeLabelString = [NSString stringWithFormat:@"报修类型 : %@",typeString];
    CGSize repairTypeLabelSize = [repairTypeLabelString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.repairTypeLabel.frame = (CGRect){{repairTypeLabelX,repairTypeLabelY},repairTypeLabelSize};
    
    //报修描述
    CGFloat repairDetailLabelX = repairTypeLabelX;
    CGFloat repairDetailLabelY = CGRectGetMaxY(self.repairTypeLabel.frame)+padding;
    NSString *repairDetailLabelString = [NSString stringWithFormat:@"报修描述 : %@",self.repair.texts];
    CGSize repairDetailLabelSize = [repairDetailLabelString sizeWithFont:[UIFont systemFontOfSize:14.0]constrainedToSize:(CGSize){ScreenWidth-padding*4,MAXFLOAT}];
    self.repairDetailLabel.frame = (CGRect){{repairDetailLabelX,repairDetailLabelY},repairDetailLabelSize};
    
    //语音信息
    CGFloat voiceLabelX = repairDetailLabelX;
    CGFloat voiceLabelY = CGRectGetMaxY(self.repairDetailLabel.frame)+padding;
    NSString *voiceLabelString = @"语音信息 : 无";
    CGSize voiceLabelSize = [voiceLabelString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.voiceLabel.frame = (CGRect){{voiceLabelX,voiceLabelY},voiceLabelSize};
    //语音按钮
    CGFloat voiceBtnX = CGRectGetMaxX(_voiceLabel.frame)-padding;
    CGFloat voiceBtnY = voiceLabelY - 3;
    CGSize voiceBtnSize = (CGSize){100,25};
    _voiceBtn.frame = (CGRect){{voiceBtnX,voiceBtnY},voiceBtnSize};
    
    //图片描述
    CGFloat pictureLabelX = voiceLabelX;
    CGFloat pictureLabelY = CGRectGetMaxY(self.voiceLabel.frame)+padding;
    NSString *pictureLabelString = @"图片描述 : 无";
    CGSize pictureLabelSize = [pictureLabelString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    self.pictureLabel.frame = (CGRect){{pictureLabelX,pictureLabelY},pictureLabelSize};
    
    //存放图片的View
    CGFloat picturesViewX = pictureLabelX;
    CGFloat picturesViewY = CGRectGetMaxY(self.pictureLabel.frame)+padding;
    NSMutableArray *picturesArray = [[NSMutableArray alloc] init];
    int picturesCount = 0;
    if (repair.pictureThree) {
        PPPicture *picture1 = [[PPPicture alloc] init];
        NSString *pictureOneUrl = [StaticFileUrl stringByAppendingString:repair.pictureOne];
        picture1.picture = pictureOneUrl;
        [picturesArray addObject:picture1];
        
        PPPicture *picture2 = [[PPPicture alloc] init];
        NSString *pictureTwoUrl = [StaticFileUrl stringByAppendingString:repair.pictureTwo];
        picture2.picture = pictureTwoUrl;
        [picturesArray addObject:picture2];
        
        PPPicture *picture3 = [[PPPicture alloc] init];
        NSString *pictureThreeUrl = [StaticFileUrl stringByAppendingString:repair.pictureThree];
        picture3.picture = pictureThreeUrl;
        [picturesArray addObject:picture3];
        picturesCount=3;
    }else if(repair.pictureTwo){
        PPPicture *picture1 = [[PPPicture alloc] init];
        NSString *pictureOneUrl = [StaticFileUrl stringByAppendingString:repair.pictureOne];
        picture1.picture = pictureOneUrl;
        [picturesArray addObject:picture1];
        
        PPPicture *picture2 = [[PPPicture alloc] init];
        NSString *pictureTwoUrl = [StaticFileUrl stringByAppendingString:repair.pictureTwo];
        picture2.picture = pictureTwoUrl;
        [picturesArray addObject:picture2];
        picturesCount = 2;
    }else if(repair.pictureOne){
        PPPicture *picture1 = [[PPPicture alloc] init];
        NSString *pictureOneUrl = [StaticFileUrl stringByAppendingString:repair.pictureOne];
        picture1.picture = pictureOneUrl;
        [picturesArray addObject:picture1];
        picturesCount = 1;
    }else{
        self.picturesView.hidden = YES;
    }
    CGSize picturesViewSize = [PPPicturesView picturesViewCount:picturesCount];
    _picturesView.frame = (CGRect){{picturesViewX,picturesViewY},picturesViewSize};
    detailViewH = CGRectGetMaxY(_picturesView.frame)+padding;
    _detailView.frame = CGRectMake(detailViewX, detailViewY, detailViewW, detailViewH);
    
    //维修信息背景
    CGFloat repairViewX = 0;
    CGFloat repairViewY = CGRectGetMaxY(_detailView.frame)+padding;
    CGFloat repairViewW = ScreenWidth;
    CGFloat repairViewH = 0;
    //维修Icon
    CGFloat repairIconX = padding*2;
    CGFloat repairIconY = padding *0.5;
    CGSize  repairIconSize = (CGSize){20,20};
    _repairIcon.frame = (CGRect){{repairIconX,repairIconY},repairIconSize};
    
    //报修详情Label
    CGFloat repairLabelX = CGRectGetMaxX(_repairIcon.frame)+padding*0.5;
    CGFloat repairLabelY = repairIconY;
    CGSize repairLabelSize = [@"报修详情" sizeWithFont:[UIFont systemFontOfSize:15.0]];
    _repairLabel.frame = (CGRect){{repairLabelX,repairLabelY},repairLabelSize};
    
    //分割线
    CGFloat repairSeparatorX = repairIconX;
    CGFloat repairSeparatorY = CGRectGetMaxY(_repairIcon.frame)+padding*0.5;
    CGSize repairSeparatorSize = (CGSize){ScreenWidth-repairIconX,1};
    _repairSeparator.frame = (CGRect){{repairSeparatorX,repairSeparatorY},repairSeparatorSize};
    
    //维修师傅
    CGFloat repairNameX = repairSeparatorX;
    CGFloat repairNameY = CGRectGetMaxY(self.repairSeparator.frame)+padding;
    NSString *repairNameString = [NSString stringWithFormat:@"维修人员 : %@",self.repair.repairWorkerName];
    CGSize repairNameSize = [repairNameString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    _repairName.frame = (CGRect){{repairNameX,repairNameY},repairNameSize};
    
    //维修联系电话
    CGFloat repairPhoneX = repairNameX;
    CGFloat repairPhoneY = CGRectGetMaxY(_repairName.frame)+padding;
    NSString *repairPhoneString = [NSString stringWithFormat:@"联系电话 : %@",self.repair.repairWorkerPhone];
    CGSize repairPhoneSize = [repairPhoneString sizeWithFont:[UIFont systemFontOfSize:14.0] ];
    _repairPhone.frame = (CGRect){{repairPhoneX,repairPhoneY},repairPhoneSize};
    
    //处理时间
    CGFloat dealTimeX = repairPhoneX;
    CGFloat dealTimeY = CGRectGetMaxY(_repairPhone.frame)+padding;
    NSString *dealTimeString = [NSString stringWithFormat:@"处理时间 : %@",self.repair.timeOne];
    CGSize dealTimeSize = [dealTimeString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    _dealTime.frame = (CGRect){{dealTimeX,dealTimeY},dealTimeSize};

    //完成时间
    CGFloat completeTimeX = dealTimeX;
    CGFloat completeTimeY = CGRectGetMaxY(_dealTime.frame)+padding;
    NSString *completeTimeString = [NSString stringWithFormat:@"完成时间 : %@",self.repair.lastEditTime];
    CGSize completeTimeSize = [completeTimeString sizeWithFont:[UIFont systemFontOfSize:14.0]];
    _completeTime.frame = (CGRect){{completeTimeX,completeTimeY},completeTimeSize};
    
    if (repair.isFixed==2) {
        self.completeTime.hidden = YES;
        repairViewH = CGRectGetMaxY(_dealTime.frame)+padding;
    }else{
        repairViewH = CGRectGetMaxY(_completeTime.frame)+padding;
    }
    _repairView.frame = CGRectMake(repairViewX, repairViewY, repairViewW, repairViewH);
    
    //评价按钮
    CGFloat evaluateBtnX = 0;
    CGFloat evaluateBtnY = CGRectGetMaxY(_repairView.frame)+padding;
    CGSize evaluateSize = (CGSize){ScreenWidth,40};
    _evaluateBtn.frame = (CGRect){{evaluateBtnX,evaluateBtnY},evaluateSize};
    
    //view视图的高度
    if (repair.isFixed==0) {
        self.repairView.hidden = YES;
        self.evaluateBtn.hidden = YES;
        _viewHeight = CGRectGetMaxY(_detailView.frame)+padding;
    }else if (repair.isFixed==2){
        self.evaluateBtn.hidden = YES;
        _viewHeight = CGRectGetMaxY(_repairView.frame)+padding;
        self.dealImage.image = [UIImage imageNamed:@"icon_tab_search_checked"];
        self.dealLabel.textColor = IWColor(240, 64, 15);
    }else{
        _viewHeight = CGRectGetMaxY(_evaluateBtn.frame)+padding;
        self.dealImage.image = [UIImage imageNamed:@"icon_tab_search_checked"];
        self.dealLabel.textColor = IWColor(240, 64, 15);
        self.completeView.image = [UIImage imageNamed:@"icon_tab_arts_checked"];
        self.completeLabel.textColor = IWColor(240, 64, 15);
    }
    
    //设置数据
    self.commitLabel.text = @"已提交";
    self.dealLabel.text = @"处理中";
    self.completeLabel.text = @"已完成";
    self.detailLabel.text = @"报修详情";
    self.nameLabel.text = [NSString stringWithFormat:@"业主姓名 : %@",self.repair.contact];
    self.phoneLabel.text = [NSString stringWithFormat:@"手机号码 : %@",self.repair.phone];
    self.timeLabel.text = [NSString stringWithFormat:@"报修时间 : %@",self.repair.timeOne];
    self.repairTypeLabel.text = @"";
    self.repairTypeLabel.text = [NSString stringWithFormat:@"报修类型 : %@",typeString];
    self.repairDetailLabel.text = [NSString stringWithFormat:@"报修描述 : %@",self.repair.texts];
    //设置图片数据
    if (repair.voice) {
        self.voiceLabel.text = @"语音信息 :";
    }else{
        self.voiceLabel.text = @"语音信息 : 无";
        self.voiceBtn.hidden = YES;
    }
    
    if (repair.pictureOne) {
        self.pictureLabel.text = @"图片信息 :";
    }else{
        self.pictureLabel.text = @"图片信息 : 无";
    }
    self.picturesView.picturesArray = picturesArray;
    self.repairLabel.text = @"维修信息";
    self.repairName.text = repairNameString;
    self.repairPhone.text = repairPhoneString;
    self.dealTime.text = dealTimeString;
    self.completeTime.text = completeTimeString;
}
/**
 *  点击了评价按钮
 */
- (void)evaluate{

}
/**
 *  语音按钮被点击
 */
- (void)voiceBtnTapped{
    IWLog(@"点击了语音按钮");
    if (self.tapVoiceBtnBlock) {
        self.tapVoiceBtnBlock();
    }
}
@end
